/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#include "core/结构数据.h"

// 定义三维坐标结构体
//typedef struct {
//    double x;
//    double y;
//    double z;
//} Point3D;

// 定义TD树节点结构体
typedef struct S_TDNode {
	struct S_TDNode* leftChild;
	struct S_TDNode* rightChild;

	vec3 data;
} TDNode;

CORE_ARRAY_HANDLE(S_TDNodeArray, TDNode*)




// 创建TD树节点
EngineAPI_EXPORT S_TDNode* f_createTDNode(vec3 data);

// 释放TD树节点及其子节点的内存
EngineAPI_EXPORT void f_destroyTDNode(S_TDNode* node);

// 在TD树中插入节点
EngineAPI_EXPORT S_TDNode* f_insertTDNode(S_TDNode** root, vec3 data, int depth);

// 判断两个点的距离是否小于等于给定容差
EngineAPI_EXPORT bool f_isWithinTolerance(vec3 p1, vec3 p2, double tolerance);

// 在TD树中查找指定的节点
EngineAPI_EXPORT bool f_findTDNode(S_TDNode* root, vec3 targetPoint, double tolerance, int depth);

// 判断一个盒子是否包含在另一个盒子中
//bool f_basic_isBoxContained(vec3 center, vec3 boxLength, vec3 target, double tolerance);

// 在TD树中查找指定范围内的节点
EngineAPI_EXPORT S_TDNodeArray* f_rangeSearch(S_TDNode* root, vec3 center, vec3 boxLength, double tolerance, int depth);


















